package ar.com.unlp.fi.lrs.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import ar.com.unlp.fi.lrs.domain.Actor;
import ar.com.unlp.fi.lrs.domain.Agent;
import ar.com.unlp.fi.lrs.domain.Group;
import ar.com.unlp.fi.lrs.service.ActorService;

/**
 * 
 * 
 * https://github.com/adlnet/xAPI-Spec/blob/master/xAPI.md#agentprofapi
 * 
 * 
 * 
 */
@RestController
@RequestMapping(value = "/actor/")
public class ActorController {

	@Autowired
	private ActorService actorService;// = new ActorService();

	@RequestMapping(value = "create", method = RequestMethod.POST, headers = "Accept=application/json")
	public Actor create(@RequestBody Actor actor) {

		actorService.create(actor);

		return actor;

	}
	
	
		
	@RequestMapping(value = "get/{idActor}", method = RequestMethod.GET, headers = "Accept=application/json")
	public Actor get(@PathVariable("idActor") int id) {

		return actorService.get(new Long(id));
	}



	@RequestMapping(value = "addToGroup/{idGroup}/{idAgent}", method = RequestMethod.GET, headers = "Accept=application/json")
	public void addAgentToGroup(@PathVariable("idGroup") int idGroup,
			@PathVariable("idAgent") int idAgent) {

		actorService.addAgentToGroup(idGroup, idAgent);

	}

	/**
	 * Retorna la lista de grupos.
	 * 
	 * 
	 * @return
	 */
	@RequestMapping(value = "getGroups/{idAgent}", method = RequestMethod.GET, headers = "Accept=application/json")
	public List<Group> getGroups(@PathVariable("idAgent") long idAgent) {

		actorService.getGroups(idAgent);
		return null;

	}

}
